import { Injection } from "../utils";
import { GaRegExp } from "../utils/ga-reg-exp";

export * from "../utils";

export interface FuncInit { RuleInit: () => void; }

export interface InjectableElement extends Function, GaRegExp, FuncInit { }

const injection = new Injection<InjectableElement>();

export const ruleInjectable = () => injection.injectable();

export const ruleInject = (name?: string | undefined) => injection.inject(name);

export const ruleBuilding = () => {
	injection.building();
	for (const rule of Array.from(injection.getElementAll())) {
		rule.RuleInit();
	}
};

export const getRule = (name: string) => { return injection.getElement(name); };

export const getRuleAll = () => { return injection.getElementAll(); };
